/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number[]}
 */
 var twoSum = function(nums, target) {
     let arr = [];
     for(let i = 0;i<nums.length;i++){
        let r = nums.indexOf(target-nums[i])
        if(r != i&&r!=-1){
            arr.push(r);
            arr.push(i);
            break;
        }
     }
     return arr;
};
console.log(twoSum([2,7,11,15],9))